home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Texteditors / Origami / bindings / fun / autolang < prev    next >
Encoding:
Text File  |  1996-09-27  |  35.9 KB  |  1,056 lines

  1. @if-using not(ocl-file-autolang)
  2.    @use (ocl-file-autolang)
  3.    ;OCL{{{}}}
  4.    ;OCL{{{  reference decription
  5.    @if-using ( FUN-REFERENCE ) ; 1 ;
  6.    Libary for automatic switching of language and hash-mode. The  mode  is
  7.    marked  with  AutoLang  or   AL   in   the   statusline.   Except   for
  8.    set-auto-language,  which  is defined as a macro, all other  operations
  9.    are defined as functions.
  10.    @fi
  11.    ;OCL}}}
  12.    ;OCL{{{  reference switching
  13.    @if-using ( FUN-REFERENCE ) ; auto-language switching ; known-endings
  14.    If mode auto-language is  active,  language  and   mode  hash-shift  are
  15.    handled  automatically  for files using language None,  depending on the
  16.    ending of the filename.
  17.  
  18.    The following languages may be switched on automatically:
  19.    @ref-start-tbl Language 8 comment 10 comment 10 # 3 Endings 24
  20.    Occam @@ "--" @@ "" @@ On @@ .ada
  21.    Occam @@ "--" @@ "" @@ Off @@ .occ
  22.    Pascal @@ "(*" @@ "*)" @@ On @@ .p / .pas
  23.    Pascal @@ "(*" @@ "*)" @@ On @@ .mod
  24.    Pascal @@ "(*" @@ "*)" @@ On @@ .h / .hh / .hpp (*)
  25.    C @@ "/*" @@ "*/" @@ On @@ .C / .c / .cc
  26.    C @@ "/*" @@ "*/" @@ On @@ .cpp
  27.    C @@ "/*" @@ "*/" @@ On @@ .l / .y
  28.    C @@ "/*" @@ "*/" @@ On @@ .h / .hh / .hpp (**)
  29.    Script @@ "#" @@ "" @@ Off @@ .sh / rc
  30.    Script @@ "#" @@ "" @@ Off @@ .awk / .pl / .sed
  31.    Script @@ "#" @@ "" @@ Off @@ .m0 .. .m9
  32.    Script @@ "#" @@ "" @@ Off @@ makefile
  33.    Script @@ "#" @@ "" @@ Off @@ Makefile
  34.    Script @@ "#" @@ "" @@ Off @@ MAKEFILE
  35.    Lisp @@ ";" @@ "" @@ On @@ .asm / .s
  36.    Lisp @@ ";" @@ "" @@ On @@ .e
  37.    Lisp @@ ";" @@ "" @@ On @@ .el
  38.    Roff @@ ".\"" @@ "" @@ Off @@ .0 .. .9
  39.    Roff @@ ".\"" @@ "" @@ Off @@ .man
  40.    Roff @@ ".\"" @@ "" @@ Off @@ .me / .ME
  41.    Roff @@ ".\"" @@ "" @@ Off @@ .mm / .MM
  42.    Roff @@ ".\"" @@ "" @@ Off @@ .ms / .MS
  43.    TeX @@ "%" @@ "" @@ Off @@ .tex / .sty / .aux
  44.    User @@ "C" @@ "" @@ Off @@ .F / .FOR / .f / .for
  45.    User @@ "||" @@ "" @@ Off @@ .m
  46.    User @@ "@comment" @@ "" @@ Off @@ .texi
  47.    @ref-end-tbl
  48.    @ref-start-item (*)
  49.    if .p / .pas were used before!
  50.    @ref-end-item
  51.    @ref-start-item (**)
  52.    if .C / .c / .cc / .cpp were used before!
  53.    @ref-end-item
  54.  
  55.    ;OCL{{{  @autolang Known endings
  56.    @ref-start-tbl Endings 60
  57.    .0 .. .9
  58.    .C
  59.    .F
  60.    .ME / .MM / .MS
  61.    .ada / .asm / .aux / .awk
  62.    .c / .cc / .cpp
  63.    .e / .el
  64.    .f / .for
  65.    .h / .hh / .hpp
  66.    .l
  67.    .m / .m0 .. .m9 / .man / .me / .mm / .mod / .ms
  68.    .occ
  69.    .p / .pas / .pl
  70.    .s / .sed / .sh / .sty
  71.    .tex / .texi
  72.    .y
  73.    MAKEFILE
  74.    Makefile
  75.    makefile
  76.    rc
  77.    @ref-end-tbl
  78.    ;OCL}}}
  79.    @fi
  80.    ;OCL}}}
  81.    ;OCL{{{  libs
  82.    @if-using not(ocl-file-delchar) @lib delchar @fi
  83.    ;OCL}}}
  84.    ;OCL{{{  variables
  85.    ( defvar
  86.       ( auto-language
  87.         auto-shift-off
  88.         auto-use-lang
  89.         auto-use-for-h
  90.         auto-lang-change
  91.         auto-used-view
  92.       )
  93.    )
  94.    ;OCL}}}
  95.    ;OCL{{{  modestring
  96.    ( defmodestring AL "AutoLang "AL )
  97.    ;OCL}}}
  98.    ;OCL{{{  set-auto-language
  99.    ;OCL{{{  reference functions
  100.    @if-using ( FUN-REFERENCE ) ; 2 ; set-auto-called
  101.    ;OCL{{{  set-auto-language
  102.    Switch the language and hash-shift mode, depending on the  filename.
  103.    If the file is not changed before calling this function,  it will be
  104.    left unchanged by this operation.
  105.    ;OCL}}}
  106.    @fi ;( FUN-REFERENCE )
  107.    ;OCL}}}
  108.    ;OCL{{{  auto-lang-switch
  109.    ( demand-load (
  110.       ( deffun auto-lang-switch
  111.          ( set auto-lang-change counter test-file-changed
  112.            set auto-used-view counter test-view
  113.            set auto-use-lang None
  114.            set auto-shift-off false
  115.            ;OCL{{{  get new language
  116.            history-edit-filename file ()
  117.            end-of-line
  118.            backward-character
  119.            if not(test-begin-line)
  120.             ( case
  121.                ;OCL{{{  .[[:digit:]] .m[[:digit:]]
  122.                ( test-char-set digit
  123.                   ( backward-character
  124.                     case
  125.                      ;OCL{{{  . -> .[[:digit:]] -> Roff
  126.                      ( test-char ".
  127.                         ( set auto-use-lang Roff
  128.                           set auto-shift-off true
  129.                         )
  130.                      )
  131.                      ;OCL}}}
  132.                      ;OCL{{{  m -> m[[:digit:]]
  133.                      ( test-char "m
  134.                         ( backward-character
  135.                           case
  136.                            ;OCL{{{  . -> .m[[:digit:]] -> Script
  137.                            ( test-char ".
  138.                               ( set auto-use-lang Script
  139.                                 set auto-shift-off true
  140.                               )
  141.                            )
  142.                            ;OCL}}}
  143.                           esac
  144.                         )
  145.                      )
  146.                      ;OCL}}}
  147.                     esac
  148.                   )
  149.                )
  150.                ;OCL}}}
  151.                ;OCL{{{  .ada
  152.                ( test-char "a
  153.                   ( backward-character
  154.                     case
  155.                      ;OCL{{{  d -> da
  156.                      ( test-char "d
  157.                         ( backward-character
  158.                           case
  159.                            ;OCL{{{  a -> ada
  160.                            ( test-char "a
  161.                               ( backward-character
  162.                                 case
  163.                                  ;OCL{{{  . -> .ada -> Occam
  164.                                  ( test-char ".
  165.                                     ( set auto-use-lang Occam )
  166.                                  )
  167.                                  ;OCL}}}
  168.                                 esac
  169.                               )
  170.                            )
  171.                            ;OCL}}}
  172.                           esac
  173.                         )
  174.                      )
  175.                      ;OCL}}}
  176.                     esac
  177.                   )
  178.                )
  179.                ;OCL}}}
  180.                ;OCL{{{  .C
  181.                ( test-char "C
  182.                   ( backward-character
  183.                     case
  184.                      ;OCL{{{  . -> .C -> C
  185.                      ( test-char ".
  186.                         ( set auto-use-lang C
  187.                           set auto-use-for-h C
  188.                         )
  189.                      )
  190.                      ;OCL}}}
  191.                     esac
  192.                   )
  193.                )
  194.                ;OCL}}}
  195.                ;OCL{{{  .c .cc rc .occ
  196.                ( test-char "c
  197.                   ( backward-character
  198.                     case
  199.                      ;OCL{{{  . -> .c -> C
  200.                      ( test-char ".
  201.                         ( set auto-use-lang C
  202.                           set auto-use-for-h C
  203.                         )
  204.                      )
  205.                      ;OCL}}}
  206.                      ;OCL{{{  r -> rc -> Script
  207.                      ( test-char "r
  208.                         ( set auto-use-lang Script
  209.                           set auto-shift-off true
  210.                         )
  211.                      )
  212.                      ;OCL}}}
  213.                      ;OCL{{{  c -> cc
  214.                      ( test-char "c
  215.                         ( backward-character
  216.                           case
  217.                            ;OCL{{{  . -> .cc -> C
  218.                            ( test-char ".
  219.                               ( set auto-use-lang C
  220.                                 set auto-use-for-h C
  221.                               )
  222.                            )
  223.                            ;OCL}}}
  224.                            ;OCL{{{  o -> occ
  225.                            ( test-char "o
  226.                               ( backward-character
  227.                                 case
  228.                                  ;OCL{{{  . -> .occ -> Occam
  229.                                  ( test-char ".
  230.                                     ( set auto-use-lang Occam
  231.                                       set auto-shift-off true
  232.                                     )
  233.                                  )
  234.                                  ;OCL}}}
  235.                                 esac
  236.                               )
  237.                            )
  238.                            ;OCL}}}
  239.                           esac
  240.                         )
  241.                      )
  242.                      ;OCL}}}
  243.                     esac
  244.                   )
  245.                )
  246.                ;OCL}}}
  247.                ;OCL{{{  .sed .mod
  248.                ( test-char "d
  249.                   ( backward-character
  250.                     case
  251.                      ;OCL{{{  e -> ed
  252.                      ( test-char "e
  253.                         ( backward-character
  254.                           case
  255.                            ;OCL{{{  s -> sed
  256.                            ( test-char "s
  257.                               ( backward-character
  258.                                 case
  259.                                  ;OCL{{{  . -> .sed -> Script
  260.                                  ( test-char ".
  261.                                     ( set auto-use-lang Script
  262.                                       set auto-shift-off true
  263.                                     )
  264.                                  )
  265.                                  ;OCL}}}
  266.                                 esac
  267.                               )
  268.                            )
  269.                            ;OCL}}}
  270.                           esac
  271.                         )
  272.                      )
  273.                      ;OCL}}}
  274.                      ;OCL{{{  o -> od
  275.                      ( test-char "o
  276.                         ( backward-character
  277.                           case
  278.                            ;OCL{{{  m -> mod
  279.                            ( test-char "m
  280.                               ( backward-character
  281.                                 case
  282.                                  ;OCL{{{  . -> .mod -> Pascal
  283.                                  ( test-char ".
  284.                                     ( set auto-use-lang Pascal )
  285.                                  )
  286.                                  ;OCL}}}
  287.                                 esac
  288.                               )
  289.                            )
  290.                            ;OCL}}}
  291.                           esac
  292.                         )
  293.                      )
  294.                      ;OCL}}}
  295.                     esac
  296.                   )
  297.                )
  298.                ;OCL}}}
  299.                ;OCL{{{  MAKEFILE MAKEFILE .ME
  300.                ( test-char "E
  301.                   ( backward-character
  302.                     case
  303.                      ;OCL{{{  M -> ME
  304.                      ( test-char "M
  305.                         ( backward-character
  306.                           case
  307.                            ;OCL{{{  . -> .ME -> roff
  308.                            ( test-char ".
  309.                               ( set auto-use-lang Roff
  310.                                 set auto-shift-off true
  311.                               )
  312.                            )
  313.                            ;OCL}}}
  314.                           esac
  315.                         )
  316.                      )
  317.                      ;OCL}}}
  318.                      ;OCL{{{  L -> LE
  319.                      ( test-char "L
  320.                         ( backward-character
  321.                           backward-character
  322.                           backward-character
  323.                           backward-character
  324.                           backward-character
  325.                           backward-character
  326.                           if test-str "MAKEFI
  327.                            ( set auto-use-lang Script
  328.                              set auto-shift-off true
  329.                            )
  330.                           fi
  331.                         )
  332.                      )
  333.                      ;OCL}}}
  334.                     esac
  335.                   )
  336.                )
  337.                ;OCL}}}
  338.                ;OCL{{{  makefile Makefile .e .me
  339.                ( test-char "e
  340.                   ( backward-character
  341.                     case
  342.                      ;OCL{{{  . -> .e -> Lisp
  343.                      ( test-char ".
  344.                         ( set auto-use-lang Lisp )
  345.                      )
  346.                      ;OCL}}}
  347.                      ;OCL{{{  m -> me
  348.                      ( test-char "m
  349.                         ( backward-character
  350.                           case
  351.                            ;OCL{{{  . -> .me -> roff
  352.                            ( test-char ".
  353.                               ( set auto-use-lang Roff
  354.                                 set auto-shift-off true
  355.                               )
  356.                            )
  357.                            ;OCL}}}
  358.                           esac
  359.                         )
  360.                      )
  361.                      ;OCL}}}
  362.                      ;OCL{{{  l -> le
  363.                      ( test-char "l
  364.                         ( backward-character
  365.                           backward-character
  366.                           backward-character
  367.                           backward-character
  368.                           backward-character
  369.                           if test-str "akefi
  370.                            ( backward-character
  371.                              if or(test-char "m test-char "M)
  372.                               ( set auto-use-lang Script
  373.                                 set auto-shift-off true
  374.                               )
  375.                              fi
  376.                            )
  377.                           fi
  378.                         )
  379.                      )
  380.                      ;OCL}}}
  381.                     esac
  382.                   )
  383.                )
  384.                ;OCL}}}
  385.                ;OCL{{{  .F
  386.                ( test-char "F
  387.                   ( backward-character
  388.                     case
  389.                      ;OCL{{{  . -> .F -> User C
  390.                      ( test-char ".
  391.                         ( set auto-use-lang -1
  392.                           set auto-shift-off true
  393.                         )
  394.                      )
  395.                      ;OCL}}}
  396.                     esac
  397.                   )
  398.                )
  399.                ;OCL}}}
  400.                ;OCL{{{  .f
  401.                ( test-char "f
  402.                   ( backward-character
  403.                     case
  404.                      ;OCL{{{  . -> .f -> User C
  405.                      ( test-char ".
  406.                         ( set auto-use-lang -1
  407.                           set auto-shift-off true
  408.                         )
  409.                      )
  410.                      ;OCL}}}
  411.                     esac
  412.                   )
  413.                )
  414.                ;OCL}}}
  415.                ;OCL{{{  .h .hh .sh
  416.                ( test-char "h
  417.                   ( backward-character
  418.                     case
  419.                      ;OCL{{{  . -> .h -> C or Pascal or no change
  420.                      ( test-char ".
  421.                         ( if auto-use-for-h
  422.                            ( set auto-use-lang auto-use-for-h )
  423.                           fi
  424.                         )
  425.                      )
  426.                      ;OCL}}}
  427.                      ;OCL{{{  h -> hh
  428.                      ( test-char "h
  429.                         ( backward-character
  430.                           case
  431.                            ;OCL{{{  . -> .hh -> C or Pascal or no change
  432.                            ( test-char ".
  433.                               ( if auto-use-for-h
  434.                                  ( set auto-use-lang auto-use-for-h )
  435.                                 fi
  436.                               )
  437.                            )
  438.                            ;OCL}}}
  439.                           esac
  440.                         )
  441.                      )
  442.                      ;OCL}}}
  443.                      ;OCL{{{  s -> sh
  444.                      ( test-char "s
  445.                         ( backward-character
  446.                           case
  447.                            ;OCL{{{  . -> .sh -> Script
  448.                            ( test-char ".
  449.                               ( set auto-use-lang Script
  450.                                 set auto-shift-off true
  451.                               )
  452.                            )
  453.                            ;OCL}}}
  454.                           esac
  455.                         )
  456.                      )
  457.                      ;OCL}}}
  458.                     esac
  459.                   )
  460.                )
  461.                ;OCL}}}
  462.                ;OCL{{{  .texi
  463.                ( test-char "i
  464.                   ( backward-character
  465.                     case
  466.                      ;OCL{{{  x -> xi
  467.                      ( test-char "x
  468.                         ( backward-character
  469.                           case
  470.                            ;OCL{{{  e -> exi
  471.                            ( test-char "e
  472.                               ( backward-character
  473.                                 case
  474.                                  ;OCL{{{  t -> texi
  475.                                  ( test-char "t
  476.                                     ( backward-character
  477.                                       case
  478.                                        ;OCL{{{  . -> .texi -> U @comment
  479.                                        ( test-char ".
  480.                                           ( set auto-use-lang -3
  481.                                             set auto-shift-off true
  482.                                           )
  483.                                        )
  484.                                        ;OCL}}}
  485.                                       esac
  486.                                     )
  487.                                  )
  488.                                  ;OCL}}}
  489.                                 esac
  490.                               )
  491.                            )
  492.                            ;OCL}}}
  493.                           esac
  494.                         )
  495.                      )
  496.                      ;OCL}}}
  497.                     esac
  498.                   )
  499.                )
  500.                ;OCL}}}
  501.                ;OCL{{{  .awk
  502.                ( test-char "k
  503.                   ( backward-character
  504.                     case
  505.                      ;OCL{{{  w -> wk
  506.                      ( test-char "w
  507.                         ( backward-character
  508.                           case
  509.                            ;OCL{{{  a -> awk
  510.                            ( test-char "a
  511.                               ( backward-character
  512.                                 case
  513.                                  ;OCL{{{  . -> .awk -> Script
  514.                                  ( test-char ".
  515.                                     ( set auto-use-lang Script
  516.                                       set auto-shift-off true
  517.                                     )
  518.                                  )
  519.                                  ;OCL}}}
  520.                                 esac
  521.                               )
  522.                            )
  523.                            ;OCL}}}
  524.                           esac
  525.                         )
  526.                      )
  527.                      ;OCL}}}
  528.                     esac
  529.                   )
  530.                )
  531.                ;OCL}}}
  532.                ;OCL{{{  .l .pl .el
  533.                ( test-char "l
  534.                   ( backward-character
  535.                     case
  536.                      ;OCL{{{  p -> pl
  537.                      ( test-char "p
  538.                         ( backward-character
  539.                           case
  540.                            ;OCL{{{  . -> .pl -> Script
  541.                            ( test-char ".
  542.                               ( set auto-use-lang Script
  543.                                 set auto-shift-off true
  544.                               )
  545.                            )
  546.                            ;OCL}}}
  547.                           esac
  548.                         )
  549.                      )
  550.                      ;OCL}}}
  551.                      ;OCL{{{  e -> el
  552.                      ( test-char "e
  553.                         ( backward-character
  554.                           case
  555.                            ;OCL{{{  . -> .el -> Lisp
  556.                            ( test-char ".
  557.                               ( set auto-use-lang Lisp )
  558.                            )
  559.                            ;OCL}}}
  560.                           esac
  561.                         )
  562.                      )
  563.                      ;OCL}}}
  564.                      ;OCL{{{  . -> .l -> C
  565.                      ( test-char ".
  566.                         ( set auto-use-lang Script )
  567.                      )
  568.                      ;OCL}}}
  569.                     esac
  570.                   )
  571.                )
  572.                ;OCL}}}
  573.                ;OCL{{{  .MM
  574.                ( test-char "M
  575.                   ( backward-character
  576.                     case
  577.                      ;OCL{{{  M -> MM
  578.                      ( test-char "M
  579.                         ( backward-character
  580.                           case
  581.                            ;OCL{{{  . -> .MM -> roff
  582.                            ( test-char ".
  583.                               ( set auto-use-lang Roff
  584.                                 set auto-shift-off true
  585.                               )
  586.                            )
  587.                            ;OCL}}}
  588.                           esac
  589.                         )
  590.                      )
  591.                      ;OCL}}}
  592.                     esac
  593.                   )
  594.                )
  595.                ;OCL}}}
  596.                ;OCL{{{  .m .mm .asm
  597.                ( test-char "m
  598.                   ( backward-character
  599.                     case
  600.                      ;OCL{{{  . -> .m -> U ||
  601.                      ( test-char ".
  602.                         ( set auto-use-lang -2
  603.                           set auto-shift-off true
  604.                         )
  605.                      )
  606.                      ;OCL}}}
  607.                      ;OCL{{{  m -> mm
  608.                      ( test-char "m
  609.                         ( backward-character
  610.                           case
  611.                            ;OCL{{{  . -> .mm -> Roff
  612.                            ( test-char ".
  613.                               ( set auto-use-lang Roff
  614.                                 set auto-shift-off true
  615.                               )
  616.                            )
  617.                            ;OCL}}}
  618.                           esac
  619.                         )
  620.                      )
  621.                      ;OCL}}}
  622.                      ;OCL{{{  s -> sm
  623.                      ( test-char "s
  624.                         ( backward-character
  625.                           case
  626.                            ;OCL{{{  a -> asm
  627.                            ( test-char "a
  628.                               ( backward-character
  629.                                 case
  630.                                  ;OCL{{{  . -> .asm -> Lisp
  631.                                  ( test-char ".
  632.                                     ( set auto-use-lang Lisp )
  633.                                  )
  634.                                  ;OCL}}}
  635.                                 esac
  636.                               )
  637.                            )
  638.                            ;OCL}}}
  639.                           esac
  640.                         )
  641.                      )
  642.                      ;OCL}}}
  643.                     esac
  644.                   )
  645.                )
  646.                ;OCL}}}
  647.                ;OCL{{{  .man
  648.                ( test-char "n
  649.                   ( backward-character
  650.                     case
  651.                      ;OCL{{{  a -> an
  652.                      ( test-char "a
  653.                         ( backward-character
  654.                           case
  655.                            ;OCL{{{  m -> man
  656.                            ( test-char "m
  657.                               ( backward-character
  658.                                 case
  659.                                  ;OCL{{{  . -> .man -> Roff
  660.                                  ( test-char ".
  661.                                     ( set auto-use-lang Roff
  662.                                       set auto-shift-off true
  663.                                     )
  664.                                  )
  665.                                  ;OCL}}}
  666.                                 esac
  667.                               )
  668.                            )
  669.                            ;OCL}}}
  670.                           esac
  671.                         )
  672.                      )
  673.                      ;OCL}}}
  674.                     esac
  675.                   )
  676.                )
  677.                ;OCL}}}
  678.                ;OCL{{{  .p .cpp .hpp
  679.                ( test-char "p
  680.                   ( backward-character
  681.                     case
  682.                      ;OCL{{{  . -> .p -> Pascal
  683.                      ( test-char ".
  684.                         ( set auto-use-lang Pascal
  685.                           set auto-use-for-h Pascal
  686.                         )
  687.                      )
  688.                      ;OCL}}}
  689.                      ;OCL{{{  p -> pp
  690.                      ( test-char "p
  691.                         ( backward-character
  692.                           case
  693.                            ;OCL{{{  c ->cpp
  694.                            ( test-char "c
  695.                               ( backward-character
  696.                                 case
  697.                                  ;OCL{{{  . -> .cpp -> C
  698.                                  ( test-char ".
  699.                                     ( set auto-use-lang C
  700.                                       set auto-use-for-h C
  701.                                     )
  702.                                  )
  703.                                  ;OCL}}}
  704.                                 esac
  705.                               )
  706.                            )
  707.                            ;OCL}}}
  708.                            ;OCL{{{  h ->hpp
  709.                            ( test-char "h
  710.                               ( backward-character
  711.                                 case
  712.                                  ;OCL{{{  . -> .hpp -> C or Pascal or no change
  713.                                  ( test-char ".
  714.                                     ( if auto-use-for-h
  715.                                        ( set auto-use-lang auto-use-for-h )
  716.                                       fi
  717.                                     )
  718.                                  )
  719.                                  ;OCL}}}
  720.                                 esac
  721.                               )
  722.                            )
  723.                            ;OCL}}}
  724.                           esac
  725.                         )
  726.                      )
  727.                      ;OCL}}}
  728.                     esac
  729.                   )
  730.                )
  731.                ;OCL}}}
  732.                ;OCL{{{  .FOR
  733.                ( test-char "R
  734.                   ( backward-character
  735.                     case
  736.                      ;OCL{{{  O -> OR
  737.                      ( test-char "O
  738.                         ( backward-character
  739.                           case
  740.                            ;OCL{{{  F -> FOR
  741.                            ( test-char "F
  742.                               ( backward-character
  743.                                 case
  744.                                  ;OCL{{{  . -> .FOR -> User C
  745.                                  ( test-char ".
  746.                                     ( set auto-use-lang -1
  747.                                       set auto-shift-off true
  748.                                     )
  749.                                  )
  750.                                  ;OCL}}}
  751.                                 esac
  752.                               )
  753.                            )
  754.                            ;OCL}}}
  755.                           esac
  756.                         )
  757.                      )
  758.                      ;OCL}}}
  759.                     esac
  760.                   )
  761.                )
  762.                ;OCL}}}
  763.                ;OCL{{{  .for
  764.                ( test-char "r
  765.                   ( backward-character
  766.                     case
  767.                      ;OCL{{{  o -> or
  768.                      ( test-char "o
  769.                         ( backward-character
  770.                           case
  771.                            ;OCL{{{  f -> for
  772.                            ( test-char "f
  773.                               ( backward-character
  774.                                 case
  775.                                  ;OCL{{{  . -> .for -> User C
  776.                                  ( test-char ".
  777.                                     ( set auto-use-lang -1
  778.                                       set auto-shift-off true
  779.                                     )
  780.                                  )
  781.                                  ;OCL}}}
  782.                                 esac
  783.                               )
  784.                            )
  785.                            ;OCL}}}
  786.                           esac
  787.                         )
  788.                      )
  789.                      ;OCL}}}
  790.                     esac
  791.                   )
  792.                )
  793.                ;OCL}}}
  794.                ;OCL{{{  .MS
  795.                ( test-char "S
  796.                   ( backward-character
  797.                     case
  798.                      ;OCL{{{  M -> MS
  799.                      ( test-char "M
  800.                         ( backward-character
  801.                           case
  802.                            ;OCL{{{  . -> .MS -> roff
  803.                            ( test-char ".
  804.                               ( set auto-use-lang Roff
  805.                                 set auto-shift-off true
  806.                               )
  807.                            )
  808.                            ;OCL}}}
  809.                           esac
  810.                         )
  811.                      )
  812.                      ;OCL}}}
  813.                     esac
  814.                   )
  815.                )
  816.                ;OCL}}}
  817.                ;OCL{{{  .ms .s
  818.                ( test-char "s
  819.                   ( backward-character
  820.                     case
  821.                      ;OCL{{{  m -> ms
  822.                      ( test-char "m
  823.                         ( backward-character
  824.                           case
  825.                            ;OCL{{{  . -> .ms -> roff
  826.                            ( test-char ".
  827.                               ( set auto-use-lang Roff
  828.                                 set auto-shift-off true
  829.                               )
  830.                            )
  831.                            ;OCL}}}
  832.                           esac
  833.                         )
  834.                      )
  835.                      ;OCL}}}
  836.                      ;OCL{{{  . -> .s -> Lisp
  837.                      ( test-char ".
  838.                         ( set auto-use-lang Lisp )
  839.                      )
  840.                      ;OCL}}}
  841.                      ;OCL{{{  a -> as
  842.                      ( test-char "a
  843.                         ( backward-character
  844.                           case
  845.                            ;OCL{{{  p -> pas
  846.                            ( test-char ".
  847.                               ( backward-character
  848.                                 case
  849.                                  ;OCL{{{  . -> .pas -> Pascal
  850.                                  ( test-char ".
  851.                                     ( set auto-use-lang Pascal
  852.                                       set auto-use-for-h Pascal
  853.                                     )
  854.                                  )
  855.                                  ;OCL}}}
  856.                                 esac
  857.                               )
  858.                            )
  859.                            ;OCL}}}
  860.                           esac
  861.                         )
  862.                      )
  863.                      ;OCL}}}
  864.                     esac
  865.                   )
  866.                )
  867.                ;OCL}}}
  868.                ;OCL{{{  .y .sty
  869.                ( test-char "y
  870.                   ( backward-character
  871.                     case
  872.                      ;OCL{{{  . -> .y -> C
  873.                      ( test-char ".
  874.                         ( set auto-use-lang C )
  875.                      )
  876.                      ;OCL}}}
  877.                      ;OCL{{{  t -> ty
  878.                      ( test-char "t
  879.                         ( backward-character
  880.                           case
  881.                            ;OCL{{{  s -> sty
  882.                            ( test-char "s
  883.                               ( backward-character
  884.                                 case
  885.                                  ;OCL{{{  . -> .sty -> TeX
  886.                                  ( test-char ".
  887.                                     ( set auto-use-lang TeX
  888.                                       set auto-shift-off true
  889.                                     )
  890.                                  )
  891.                                  ;OCL}}}
  892.                                 esac
  893.                               )
  894.                            )
  895.                            ;OCL}}}
  896.                           esac
  897.                         )
  898.                      )
  899.                      ;OCL}}}
  900.                     esac
  901.                   )
  902.                )
  903.                ;OCL}}}
  904.                ;OCL{{{  .tex .aux
  905.                ( test-char "x
  906.                   ( backward-character
  907.                     case
  908.                      ;OCL{{{  e -> ex
  909.                      ( test-char "e
  910.                         ( backward-character
  911.                           case
  912.                            ;OCL{{{  t -> tex
  913.                            ( test-char "t
  914.                               ( backward-character
  915.                                 case
  916.                                  ;OCL{{{  . -> .tex -> TeX
  917.                                  ( test-char ".
  918.                                     ( set auto-use-lang TeX
  919.                                       set auto-shift-off true
  920.                                     )
  921.                                  )
  922.                                  ;OCL}}}
  923.                                 esac
  924.                               )
  925.                            )
  926.                            ;OCL}}}
  927.                           esac
  928.                         )
  929.                      )
  930.                      ;OCL}}}
  931.                      ;OCL{{{  u -> ux
  932.                      ( test-char "u
  933.                         ( backward-character
  934.                           case
  935.                            ;OCL{{{  a -> aux
  936.                            ( test-char "a
  937.                               ( backward-character
  938.                                 case
  939.                                  ;OCL{{{  . -> .aux -> TeX
  940.                                  ( test-char ".
  941.                                     ( set auto-use-lang TeX
  942.                                       set auto-shift-off true
  943.                                     )
  944.                                  )
  945.                                  ;OCL}}}
  946.                                 esac
  947.                               )
  948.                            )
  949.                            ;OCL}}}
  950.                           esac
  951.                         )
  952.                      )
  953.                      ;OCL}}}
  954.                     esac
  955.                   )
  956.                )
  957.                ;OCL}}}
  958.               esac
  959.             )
  960.            fi
  961.            beginning-of-line
  962.            delete-to-end-of-line
  963.            newline-and-indent
  964.            ;OCL}}}
  965.            if auto-used-view ( delete-mode-view ) fi
  966.            ;OCL{{{  set shift and language
  967.            if auto-shift-off ( delete-mode-hash-shift ) fi
  968.            case
  969.             ;OCL{{{  >0==auto-use-lang
  970.             ( >(auto-use-lang 0)
  971.                ( set-language insert-ascii auto-use-lang
  972.                  if or(=(auto-use-lang C) =(auto-use-lang Pascal))
  973.                   ( add-mode-hash-shift )
  974.                  fi
  975.                )
  976.             )
  977.             ;OCL}}}
  978.             ;OCL{{{  -1==C
  979.             ( =(auto-use-lang -1)
  980.                ( set-language User "C newline-and-indent  newline-and-indent )
  981.             )
  982.             ;OCL}}}
  983.             ;OCL{{{  -2==||
  984.             ( =(auto-use-lang -2)
  985.                ( set-language User "| "| newline-and-indent newline-and-indent )
  986.             )
  987.             ;OCL}}}
  988.             ;OCL{{{  -3==@comment
  989.             ( =(auto-use-lang -3)
  990.                ( set-language User "@ "comment newline-and-indent newline-and-indent )
  991.             )
  992.             ;OCL}}}
  993.            esac
  994.            ;OCL}}}
  995.            if auto-used-view ( add-mode-view ) fi
  996.            if not(auto-lang-change)
  997.             ( set-file-unchanged )
  998.            fi
  999.          )
  1000.       )
  1001.    ))
  1002.    ;OCL}}}
  1003.    ( defmac set-auto-language
  1004.       ( if and(auto-language test-language None =(file-type 0))
  1005.          ( auto-lang-switch )
  1006.         fi
  1007.       )
  1008.    )
  1009.    ;OCL}}}
  1010.    ;OCL{{{  add-mode-auto-language
  1011.    ;OCL{{{  reference
  1012.    @if-using ( FUN-REFERENCE ) ; 2 ; add-auto-called
  1013.    ;OCL{{{  add-mode-auto-language
  1014.    Switch on auto-language mode
  1015.    ;OCL}}}
  1016.    @fi ;( FUN-REFERENCE )
  1017.    ;OCL}}}
  1018.    ( deffun add-mode-auto-language
  1019.       ( set auto-language true
  1020.         set-user-mode AL
  1021.       )
  1022.    )
  1023.    ;OCL}}}
  1024.    ;OCL{{{  delete-mode-auto-language
  1025.    ;OCL{{{  reference functions
  1026.    @if-using ( FUN-REFERENCE ) ; 2 ; del-auto-called
  1027.    ;OCL{{{  delete-mode-auto-language
  1028.    Switch off auto-language mode
  1029.    ;OCL}}}
  1030.    @fi ;( FUN-REFERENCE )
  1031.    ;OCL}}}
  1032.    ( deffun delete-mode-auto-language
  1033.       ( set auto-language false
  1034.         reset-user-mode AL
  1035.         load-function not(auto-lang-switch)
  1036.       )
  1037.    )
  1038.    ;OCL}}}
  1039.    ;OCL{{{  reference hooks
  1040.    @if-using ( FUN-REFERENCE ) ; 3 ;
  1041.    The libary functions are marked as demand-loading.
  1042.    @fi
  1043.    ;OCL}}}
  1044.    ;OCL{{{  undeclares
  1045.    ( undeclare
  1046.       ( auto-shift-off
  1047.         auto-use-lang
  1048.         auto-use-for-h
  1049.         auto-lang-change
  1050.         auto-used-view
  1051.         auto-lang-switch
  1052.       )
  1053.    )
  1054.    ;OCL}}}
  1055. @fi
  1056.